<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>JS Test Runner</title>
    <!--
        路径说明:
        pywebview 加载本地文件时，路径通常相对于项目根目录（E:/repos/lm_chatroom/）。
        因此，formatters.js 应该是 ../../ui/utils/formatters.js
        formatters.test.js 应该是 ../../ui/utils/formatters.test.js
    -->
    <script src="../../ui/utils/formatters.js"></script>
    <script src="../../ui/utils/formatters.test.js"></script>
</head>
<body>
    <h1>JavaScript Test Runner</h1>
    <p>Check the console for test results. Test results will also be available on <code>window.jsTestResults</code>.</p>
    <script>
        // Automatically run tests when the page loads and store the result.
        // The pytest script will retrieve this result.
        window.jsTestResults = null; // Initialize
        try {
            // Ensure runFormatterTests is defined before calling it
            if (typeof runFormatterTests === 'function') {
                window.jsTestResults = runFormatterTests();
                console.log("JS tests executed. Results stored in window.jsTestResults:", window.jsTestResults);
            } else {
                console.error("runFormatterTests function not found. Make sure formatters.test.js is loaded correctly and defines this function.");
                window.jsTestResults = { error: "runFormatterTests function not found", passed: 0, failed: 1, total: 1 };
            }
        } catch (e) {
            console.error("Error running JS tests:", e);
            window.jsTestResults = { error: e.toString(), passed: 0, failed: 1, total: 1 };
        }
    </script>
</body>
</html>